package goescape

import "fmt"

type title struct {
	// Set title.
	Set func(name string) Escape
	// Restore saved title.
	Restore,
	// Save title.
	Save Escape
}

// Return escape code for title control.
func Title() title {
	return title{
		Set: func(name string) Escape {
			return Escape(fmt.Sprintf("\x1b]2;%s\x07", name))
		},
		Restore: "\x1b[23t",
		Save:    "\x1b[22t",
	}
}
